﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NetFramework;
namespace GameServer
{
    public enum STATE
    {
        none,//空着
        read,//已经有个连接
        isonline,//正在玩游戏!
        iszhunbei//准备进入游戏
    }
    /// <summary>
    /// 玩家
    /// </summary>
    public class User
    {
        //未出的牌
        public List<int> cards;
        //用户名
        public string username;
        //在服务器上的唯一的连接的ID
        public string connstringid;
        //是否在线
        public STATE state = STATE.none;
        //所在的桌子
        public Table table = null;
        //token
        public AsyncUserToken token;
        public User(string connectid,AsyncUserToken token)
        {
            this.connstringid = connectid;
            state = STATE.none;
            this.token = token;
        }
        /// <summary>
        /// 准备中,可以进行发牌
        /// </summary>
        public void Zhunbei()
        {
            state = STATE.iszhunbei;
        }
        /// <summary>
        /// 改为在线
        /// </summary>
        public void OnLine()
        {
            state = STATE.isonline;
        }
        /// <summary>
        /// 改为离线
        /// </summary>
        public void OffLine()
        {
            state = STATE.none;
            username = "";
            connstringid = "";
        }
        //删除牌
        public void RemoveCards(List<int> cards1)
        {
            foreach (int temp in cards1)
            {
                cards.Remove(temp);
            }
        }
        //添加牌
        public void AddCard(List<int> cards1)
        {
            foreach (int temp in cards1)
            {
                cards.Add(temp);
            }
        }
        /// <summary>
        /// 判断断开的是否是这个玩家
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public bool isequal(string id)
        {
            return connstringid == id;
        }
    }
}
